<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <% String path = request.getContextPath();%>
    	<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    	<title>添加文章 </title>
    	
<jsp:include page="/web/manager/inc/header.jsp"></jsp:include>

	 
                <div class="add_Test main_container">
                    <div class="row page-titles mx-0">
                        <div class="col-sm-6 p-md-0">
                            <div class="welcome-text">
                                <h4 class="text-primary">添加文章</h4>
                                <p class="mb-0">Add New Article</p>
                            </div>
                        </div>
                       
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div class="card shadow mb-4">
                                <div class="card-header" id="edit">
                                    <h4 class="card-title">编辑文章</h4>
                                </div>
                                <div class="card-body">
                                    <div class="basic-form">
                                    
                                    
                                       <form target="frame1" method="post" action="<%=path %>/ArticleController?action=addArticle" id="save"  enctype="multipart/form-data" >
                                        <h5 class="card-title">选择文章类别</h5>
                                               <div class="col-xl-4">
                                                    <div class="form-group">                                 
                                                        <select id="subject" name="subject_id" class="form-control form-select">
                                                            <c:forEach items="${subjects}" var="subject">
                                                            	<option value="${subject.id }"> ${subject.name} </option>   
                                                            </c:forEach>
                                                        </select>
                                                        
                                                    </div>
                                                </div>
                                            <div class="row">
                                                <div class="col-xl-6">
                                                    <div class="form-group">
                                                       <span>标题</span>
                                                        <input id="Tit" name="title" type="text" class="form-control"  />
                                                    </div>
                                                </div>
                                                <div class="">
                                                    <div class="form-group">
                                                       <span>内容</span>
                                                       <textarea id="Cont" name="content" id="" cols="30" rows="10" class="form-control"></textarea>
                                                        
                                                    </div>
                                                </div>
                                                <div class="">
                                                    <div class="form-group">
                                                       <span id="addpic">添加照片</span>
                                                        <input id="picture" type="file" name="pic" />
                                                    </div>
                                                </div>
                                                <p id="alarm"> </p> 
                                                <div class="col-xl-12">
                                                    <div class="form-group">
                                                        <button id="but" class="btn btn-primary float-end" >保存 </button>
                                                    </div>
                                                </div>
                                            </div>
                                        </form>
                                        <iframe name="frame1" frameborder="0" id="frame"></iframe>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
<jsp:include page="/web/manager/inc/footer.jsp"></jsp:include>
 <script type="text/javascript">
            $(function(){
            	
	            	$("#save").submit(function(){
		            	if(!($("#picture").get(0).files[0])||$("#Tit").val()==""){
	            			$("#edit h3").remove();
	            			$("#edit").append("<h3>输入不能为空</h3>")
	            				return false;
		            	}
		            	else{
		            		$("#edit h3").remove();
		            		alert("添加成功");
		            		
		            	}
	            		})
	            	
            		
            	})
                                  
 </script>
										